package com.ruoyi.common.core.config.domain;

import com.ruoyi.common.core.config.mybatis.enhance.LambdaResolve;
import com.ruoyi.common.core.config.mybatis.enhance.SFunction;
import lombok.Data;

/**
 * 增加mybatis-plus自定义方法的参数对象
 *
 * @author Cao.Yu
 * @date 2023-06-08 17:44
 */
@Data
public class BatisParams {

    private String fieldName;

    private String fieldValue;

    public BatisParams(String fieldName, String fieldValue) {
        this.fieldName = fieldName;
        this.fieldValue = fieldValue;
    }

    public BatisParams(String fieldValue) {
        this.fieldName = "parent_id";
        this.fieldValue = fieldValue;
    }

    public static <T, R> BatisParams lambdaBuild(SFunction<T, R> func, String fieldValue) {
        return new BatisParams(LambdaResolve.resolve(func), fieldValue);
    }

}
